<?php
//include './common/home.php';
//屏蔽notice错误
error_reporting(E_ALL ^ E_NOTICE);

$title  = '丁江的论坛';
/*
$table  = DB_TABLE_CG;
$fields = 'classname,orderby,compere,cid';
$where  = 'where parentid=0 order by orderby';
$data0   = select($link,$table,$fields,$where);
//var_dump($data0);
$count   = count($data0);
$where  = 'where parentid=2 order by orderby desc';
$data   = select($link,$table,$fields,$where);


$compere = 'tessttt00000';
$Ctime   = date('Y-m-d H:m:s',time());
$web_site = WEB_SITE;
//var_dump($compere);
$vars = compact('title','data0','data','Ctime','count','web_site','count');
display('num_two.html',$vars);

*/

$data_big = select($link,DB_TABLE_CG,'*', "order by orderby");
//var_dump($data_big);
/********************************************************/
$data_s = select($link,DB_TABLE_CG,'*',"where parentid>0  order by orderby");
//var_dump($data_s);
$cid = $data_s[0]['cid'];
//var_dump($cid);

$data_d = select($link,DB_TABLE_DETAIL,'addtime',"where first=1 and classid=$cid order by addtime");
//var_dump($data_d);


/***********************************************/
//var_dump($data_big[0]['cid']);
//取最后发布的帖子
$res1 = select($link,DB_TABLE_DETAIL,'max(addtime)',"where first=1 order by addtime");
//var_dump($res1);

//取最大时间戳
$addtime1 = $res1[0]['max(addtime)'];
//var_dump($addtime1);

//取最后发表帖子的所有信息
$res2 = select($link,DB_TABLE_DETAIL,'*',"where addtime=$addtime1");
//var_dump($res2);

//	取出用户id
$authorid = $res2[0]['authorid'];
//var_dump($authorid);

//根据用户id查username
$res3 = select($link,DB_TABLE_USER,'*',"where uid=$authorid");
//var_dump($res3);



/******获取板块的具体信息************************************/
/*
$table  = DB_TABLE_CG;
$fields = 'cid';
$where  = "where lastpost=1";
$res = select($link,$table,$fields,$where);
//var_dump($res);
$num = count($res);
//var_dump($num);

for ($i=0;$i<$num;$i++) {
	$cid[] = $res[$i]['cid'];
	//var_dump($res[$i]['cid']);
}

foreach ($cid as $k => $v) {
	
	$cid 	 = $v; 
	//var_dump($cid);
	//用 classid=cid 取值
	$table   = DB_TABLE_DETAIL;
	$fields  = 'authorid , first, title, addtime,id,classid';
	$where   = "where first=1 and classid=$cid order by addtime desc limit 0,1";
	$data_one3 = select($link,$table,$fields,$where);
	//var_dump($data_one3);
	$authorid  = $data_one3[0][authorid];
	//var_dump($authorid);
	//var_dump($data_one3[0]['id']);

	//用uid在bbs_user表中取username
	$table  = DB_TABLE_USER;
	$fields = 'username';
	$where  = "where uid=$authorid";
	$data_user = select($link,$table,$fields,$where);
	//var_dump($data_user);

}




*/
//var_dump($data_one3);
//查询板块获取总条数(由classid值决定)
$table  = DB_TABLE_DETAIL." where first=1 and classid=$cid";
$fields = id;
$total  = idCount($link,$table,$fields);  

/***********今日发帖数********************************/
//var_dump($res[0]['addtime']);

for ($i=0;$i<count($data_d);$i++){

	if ($data_d[$i]['addtime'] > strtotime('00:00:00')) {

		$rows[] = $data_d[$i]['addtime'];
		//var_dump($rows);
		$today_count = count($rows);

		//var_dump($today_count);
	}

}


/********************************************************/

$vars = compact('title','web_site','data_one1','data_one2','res','data_one3','data_user','cid','today_count','total','count','data_big','res2','res3');
display('num_one.html',$vars);




